package com.dk.controller;

import com.dk.em.Result;
import com.dk.pojo.WmRtVendor;
import com.dk.service.WmRtVendorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("RTVendor")
@Api(tags = "供应商服务")
@RefreshScope     //热更新
public class WmRtVendorController {

    @Autowired
    private WmRtVendorService rtVendorService;

    /*增加*/
    @PostMapping
    @ApiOperation("添加供应商")
    public Result insertrtVendor(@RequestBody WmRtVendor rtVendor){
        rtVendorService.insertrtVendor(rtVendor);
        return Result.OK();
    }

    /*根据id删除*/
    @DeleteMapping
    @ApiOperation("删除供应商")
    @ApiImplicitParam(name = "供应商退货id",value = "id")
    public Result deletertVendor(Long id){
        rtVendorService.deleteById(id);
        return Result.OK();
    }

    /*批量删除*/
    @DeleteMapping("deleteAllItem")
    public Result deleteAllItem(@RequestBody List<String> ids){
        rtVendorService.deleteAllByIds(ids);
        return Result.OK();
    }

    /*查询*/
    @GetMapping
    @ApiOperation("查询供应商")
    public Result getrtVendor(){
        List<WmRtVendor> list = rtVendorService.selectrtVendor();
        return Result.OK().setData(list);
    }

    /*修改*/
    @PutMapping
    @ApiOperation("修改供应商")
    public Result updatertVendor(@RequestBody WmRtVendor rtVendor){
        rtVendorService.updateItem(rtVendor);
        return Result.OK();
    }
}
